package com.example.smartcamera;

import com.example.smartcamera.slice.RealTimeAbilitySlice;
import ohos.aafwk.ability.Ability;
import ohos.aafwk.content.Intent;
import ohos.bundle.IBundleManager;
import ohos.security.SystemPermission;

public class MainAbility extends Ability {
    private static final int REQUEST_CODE = 0X01;

    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        requestPermission();
        super.setMainRoute(RealTimeAbilitySlice.class.getName());
    }

    //请求权限
    private void requestPermission() {
        if (verifyCallingOrSelfPermission(SystemPermission. READ_MEDIA) != IBundleManager.PERMISSION_GRANTED) {
            requestPermissionsFromUser(new String[]{SystemPermission. READ_MEDIA}, REQUEST_CODE);
        }
    }

}
